<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends MY_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('page_model');
		$this->load->model('article_model');
		$this->load->model('gallery_model');
		$this->load->model('coltypes_model');
	}
	//箱包
	public function index($id='',$page=1){
		$data['nav']=$this->db->order_by('sort_id','asc')->get_where('coltypes',array('cid'=>2))->result_array();
		if(empty($id)){
       $id=$data['nav'][0]['id'];
    }
    $data['nowId']=$id;
		//计算当前页面新闻总条数
		$where=array('audit'=>1,'ctype'=>$id,'cid'=>2);
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] =6;//每页显示的条数
		$config['use_page_numbers'] = TRUE;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		
		$data['seo']=$this->db->get_where('columns',array('id'=>2))->row_array();//获取seo
		$this->load->view('product',$data);
	}
	
	public function inx_ajax(){
		$page=$_GET['page'];
		$id=$_GET['id'];
		header('Content-type:application/json');
		//计算当前页面新闻总条数
		$where= array('audit'=>1,'ctype'=>$id,'cid'=>2);;
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] = 6;//每页显示的条数
		//判断是否有下一页
		if($config['total_rows']>$page*$config['per_page']){
			$back['status']= 'yes';
		}else{
			$back['status']= 'no';
		}
		$config['use_page_numbers'] = TRUE ;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		$html= "";
		foreach ($data['fenye']['new_con'] as $k =>$v){
			$photo=UPLOAD_URL.tag_photo($v['photo']);
			$photo1=UPLOAD_URL.tag_photo($v['photo1']);
			if($k%2==0){
				$html.='<dl class="fl">';
			}else{
				$html.='<dl class="fr">';
			}
			$html.= '<dt><img src="'.$photo.'" alt=""></dt>
                    	<dd>
                    		<span>'.$v['title'].'</span>
                    		<p><img src="'.$photo1.'" alt=""></p>
                    	</dd>
                    </dl>' ;
		}
		$back['list']=$html;
		exit(json_encode($back));
	}
	
	//服饰
	public function index1($id='',$page=1){
		$data['nav']=$this->db->order_by('sort_id','asc')->get_where('coltypes',array('cid'=>3))->result_array();
		if(empty($id)){
			$id=$data['nav'][0]['id'];
		}
		$data['nowId']=$id;
		//计算当前页面新闻总条数
		$where=array('audit'=>1,'ctype'=>$id,'cid'=>3);
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] =6;//每页显示的条数
		$config['use_page_numbers'] = TRUE;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		
		$data['seo']=$this->db->get_where('columns',array('id'=>3))->row_array();//获取seo
		$this->load->view('product1',$data);
	}
	
	public function inx1_ajax(){
		$page=$_GET['page'];
		$id=$_GET['id'];
		header('Content-type:application/json');
		//计算当前页面新闻总条数
		$where= array('audit'=>1,'ctype'=>$id,'cid'=>3);
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] = 6;//每页显示的条数
		//判断是否有下一页
		if($config['total_rows']>$page*$config['per_page']){
			$back['status']= 'yes';
		}else{
			$back['status']= 'no';
		}
		$config['use_page_numbers'] = TRUE ;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		$html= "";
		foreach ($data['fenye']['new_con'] as $k =>$v){
			$photo=UPLOAD_URL.tag_photo($v['photo']);
			$photo1=UPLOAD_URL.tag_photo($v['photo1']);
			if($k%2==0){
				$html.='<dl class="fl">';
			}else{
				$html.='<dl class="fr">';
			}
			$html.= '<dt><img src="'.$photo.'" alt=""></dt>
                    	<dd>
                    		<span>'.$v['title'].'</span>
                    		<p><img src="'.$photo1.'" alt=""></p>
                    	</dd>
                    </dl>' ;
		}
		$back['list']=$html;
		exit(json_encode($back));
	}
	
	
	//生活/家居
	public function index2($id='',$page=1){
		$data['nav']=$this->db->order_by('sort_id','asc')->get_where('coltypes',array('cid'=>4))->result_array();
		if(empty($id)){
			$id=$data['nav'][0]['id'];
		}
		$data['nowId']=$id;
		//计算当前页面新闻总条数
		$where=array('audit'=>1,'ctype'=>$id,'cid'=>4);
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] =6;//每页显示的条数
		$config['use_page_numbers'] = TRUE;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		
		$data['seo']=$this->db->get_where('columns',array('id'=>4))->row_array();//获取seo
		$this->load->view('product2',$data);
	}
	
	public function inx2_ajax(){
		$page=$_GET['page'];
		$id=$_GET['id'];
		header('Content-type:application/json');
		//计算当前页面新闻总条数
		$where= array('audit'=>1,'ctype'=>$id,'cid'=>4);
		$config['total_rows'] = $this->db->where($where)->from('article')->count_all_results();
		$config['per_page'] = 6;//每页显示的条数
		//判断是否有下一页
		if($config['total_rows']>$page*$config['per_page']){
			$back['status']= 'yes';
		}else{
			$back['status']= 'no';
		}
		$config['use_page_numbers'] = TRUE ;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->news_page($config,$id,$where,$page);
		$html= "";
		foreach ($data['fenye']['new_con'] as $k =>$v){
			$photo=UPLOAD_URL.tag_photo($v['photo']);
			$photo1=UPLOAD_URL.tag_photo($v['photo1']);
			if($k%2==0){
				$html.='<dl class="fl">';
			}else{
				$html.='<dl class="fr">';
			}
			$html.= '<dt><img src="'.$photo.'" alt=""></dt>
                    	<dd>
                    		<span>'.$v['title'].'</span>
                    		<p><img src="'.$photo1.'" alt=""></p>
                    	</dd>
                    </dl>' ;
		}
		$back['list']=$html;
		exit(json_encode($back));
	}
	
	
	
	
	
	
	
	
	
}